package com.amithkoujalgi.myapp.utils;

import com.amithkoujalgi.myapp.core.AppConstants;

public class GoogleURLBuilder {
	private static String getScopesString(String[] scopes) {
		String scopeURL = "";
		for (String scope : scopes) {
			scopeURL += scope + " ";
		}
		scopeURL = scopeURL.trim();
		scopeURL = scopeURL.replace(" ", "%20");
		return scopeURL;
	}

	public static String getLoginURL(String... scopes) {
		String url = AppConstants.GoogleURL.OAUTH_BROWSER_LOGIN_URL
				+ "?redirect_uri=" + AppConstants.REDIRECT_URI
				+ "&response_type=code&client_id=" + AppConstants.CLIENT_ID
				+ "&scope=" + GoogleURLBuilder.getScopesString(scopes);
		return url;
	}
}
